source conda/bin/activate privratsky rmarkdown::render(‘./5_Clustering_res_0.5/5_Clustering_res_0.5.Rmd’)

Changes in myeloid and kidney cells after CLP - Analysis of 2 x 10X scRNA-seq samples from 2 pools of WT mice (3 Sham + 3 CLP): comparison of gene expression in different cell populations

rainbow1.7c <- c("#B3ADD3", "#80617D", "#A75769", "#F9C971", 
    "#A3C587", "#40A8AC", "#296D71")
slices <- rep(1, length(rainbow1.7c))
pie(slices, col = rainbow1.7c)

rainbow2.6c <- c("#03539C", "#12999E", "#B7CE05", "#FAEB09", 
    "#FDA908", "#E82564")
slices <- rep(1, length(rainbow2.6c))
pie(slices, col = rainbow2.6c)

rainbow3.5c <- c("#f66e6e", "#f6b36e", "#f5f66e", "#6ef3f6", 
    "#9c6ef6")
slices <- rep(1, length(rainbow3.5c))
pie(slices, col = rainbow3.5c)

rainbow4.12c <- c("#1a1334", "#27294a", "#01545a", "#017352", 
    "#02c383", "#abd962", "#fbbf46", "#ef6b32", "#ee0445", "#a22b5e", 
    "#710062", "#022c7d")
slices <- rep(1, length(rainbow4.12c))
pie(slices, col = rainbow4.12c)

indir <- "./processedData/2_1_Resolution_choice"
outdir <- "./processedData/5_Clustering_res_0.5"
dir.create(outdir, recursive = T)
library(Seurat)
integrated <- readRDS(paste0(indir, "/8.integrated.rds"))
integrated
## An object of class Seurat 
## 24399 features across 18055 samples within 2 assays 
## Active assay: integrated (2000 features, 2000 variable features)
##  1 other assay present: RNA
##  2 dimensional reductions calculated: pca, umap
Idents(integrated) <- "integrated_snn_res.0.5"
table(integrated@active.ident)
## 
##    0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15 
## 2472 2283 2201 1962 1651 1535 1078  588  519  463  447  435  428  382  344  325 
##   16   17   18   19   20   21   22 
##  207  185  184  101   89   88   88
# pal <- colorRampPalette(c('#12999E', '#FAEB09', '#E82564',
# '#03539C'))
pal <- colorRampPalette(rainbow1.7c)
levels <- levels(integrated$integrated_snn_res.0.5)
colors.clusters <- pal(length(levels))
colors.clusters.2 <- colors.clusters[c(11:14, 1, 7, 2, 20, 3:4, 
    8, 5, 9, 15, 6, 10, 16, 21, 17:18, 22:23, 19)]
names(colors.clusters.2) <- levels
colors.clusters.2
##         0         1         2         3         4         5         6         7 
## "#E2A96E" "#F9C971" "#E1C776" "#CAC67D" "#B3ADD3" "#985A70" "#A598BB" "#3B9DA1" 
##         8         9        10        11        12        13        14        15 
## "#9783A4" "#896E8C" "#A3576A" "#83607B" "#B56B6A" "#B2C583" "#8E5D75" "#CC8A6C" 
##        16        17        18        19        20        21        22 
## "#99C28A" "#358D91" "#7EBA94" "#63B29E" "#2F7D81" "#296D71" "#48AAA8"
slices <- rep(1, length(levels))
pie(slices, col = colors.clusters.2, labels = names(colors.clusters.2))

d <- DimPlot(integrated, reduction = "umap", pt.size = 0.2, label = T, 
    label.size = 6, cols = colors.clusters.2)
d

pdf(paste0(outdir, "/1_DimPlot_umap_clusters_pc50_res0.5.pdf"), 
    width = 10, height = 8)
d
dev.off()
## png 
##   2
colors.samples <- c("#12999E", "#FDA908")
names(colors.samples) <- levels(as.factor(integrated$sample.id))
slices <- rep(1, length(colors.samples))
pie(slices, col = colors.samples, labels = names(colors.samples))

p1 <- DimPlot(integrated, reduction = "umap", group.by = "sample.id", 
    pt.size = 0.2, cols = colors.samples)
p2 <- DimPlot(integrated, reduction = "umap", label = TRUE, pt.size = 0.2, 
    label.size = 6, cols = colors.clusters.2)
library(cowplot)
plot_grid(p1, p2)

pdf(paste0(outdir, "/2_2DimPlots_umap_samples_clusters_pc50_res0.5.pdf"), 
    width = 18, height = 8)
plot_grid(p1, p2)
dev.off()
## png 
##   2
d <- DimPlot(integrated, reduction = "umap", group.by = "sample.id", 
    split.by = "sample.id", pt.size = 0.2, ncol = 2, cols = colors.samples)
d

pdf(paste0(outdir, "/3_DimPlot_umap_split_by_samples.pdf"), width = 16, 
    height = 9)
d
dev.off()
## png 
##   2
f <- FeaturePlot(integrated, features = c("Nphs2", "Slc5a2", 
    "Clcnka", "Slc12a1", "Ptgs2", "Slc12a3", "Calb1", "Aqp2", 
    "Slc4a1", "Slc26a4", "Slc14a2", "Upk1a", "Cd22", "Adgre1", 
    "Pecam1", "Pdgfrb", "Cd68", "Cd14", "Acta2", "Csf3r", "Cd4"), 
    min.cutoff = "q9", order = T)
f

pdf(paste0(outdir, "/4_FeaturePlot_cellID.pdf"), width = 28, 
    height = 42)
f
dev.off()
## png 
##   2

##Annotation of markers based on cluster markers from Susztak Science paper (Park et al., Science 360, 758–763 (2018) and Kidney International (2019) 95, 787–796; https://doi.org/10.1016/

https://science.sciencemag.org/content/360/6390/758.long https://www.kidney-international.org/article/S0085-2538(18)30912-8/fulltext

#Podocyte markers -> cluster 28

f2 <- FeaturePlot(integrated, features = c("Nphs2", "Podxl"), 
    min.cutoff = "q9")
f2

pdf(paste0(outdir, "/5_FeaturePlot_Podo.pdf"), width = 14, height = 7)
f2
dev.off()
## png 
##   2

#Endothelial markers -> cluster 15

f3 <- FeaturePlot(integrated, features = c("Plat", "Pecam1"), 
    min.cutoff = "q9")
f3

pdf(paste0(outdir, "/6_FeaturePlot_Endo.pdf"), width = 14, height = 7)
f3
dev.off()
## png 
##   2

#PT-S1 markers -> clusters 7,8,9

f4 <- FeaturePlot(integrated, features = c("Slc5a2", "Slc5a12"), 
    min.cutoff = "q9")
f4

pdf(paste0(outdir, "/7_FeaturePlot_PTs1.pdf"), width = 14, height = 7)
f4
dev.off()
## png 
##   2

#PT-S2 markers

f5 <- FeaturePlot(integrated, features = c("Fxyd2", "Hrsp12"), 
    min.cutoff = "q9")
f5

pdf(paste0(outdir, "/8_FeaturePlot_PTs2.pdf"), width = 7, height = 7)
f5
dev.off()
## png 
##   2

#PT-S3 markers -> cluster 5

f6 <- FeaturePlot(integrated, features = c("Atp11a", "Slc13a3"), 
    min.cutoff = "q9")
f6

pdf(paste0(outdir, "/9_FeaturePlot_PTs3.pdf"), width = 14, height = 7)
f6
dev.off()
## png 
##   2

#Loop of Henle -> clusters 11, 13, 18

f7 <- FeaturePlot(integrated, features = c("Slc12a1", "Umod"), 
    min.cutoff = "q9")
f7

pdf(paste0(outdir, "/10_FeaturePlot_LOH.pdf"), width = 14, height = 7)
f7
dev.off()
## png 
##   2

#Distal CT -> cluster 10

f8 <- FeaturePlot(integrated, features = c("Slc12a3", "Pvalb"), 
    min.cutoff = "q9")
f8

pdf(paste0(outdir, "/11_FeaturePlot_DCT.pdf"), width = 14, height = 7)
f8
dev.off()
## png 
##   2

#Conn Tubule -> clusters 6, 20, 21, 29

f21 <- FeaturePlot(integrated, features = c("Calb1"), min.cutoff = "q9")
f21

pdf(paste0(outdir, "/12_FeaturePlot_ConnTub.pdf"), width = 7, 
    height = 7)
f21
dev.off()
## png 
##   2

#CD PC -> cluster 21

f9 <- FeaturePlot(integrated, features = c("Aqp2", "Hsd11b2"), 
    min.cutoff = "q9")
f9

pdf(paste0(outdir, "/13_FeaturePlot_CD-PC.pdf"), width = 14, 
    height = 7)
f9
dev.off()
## png 
##   2

#CD-IC -> clusters 24, 29, 39

f10 <- FeaturePlot(integrated, features = c("Atp6v1g3", "Atp6v0d2"), 
    min.cutoff = "q9")
f10

pdf(paste0(outdir, "/14_FeaturePlot_CD-IC.pdf"), width = 14, 
    height = 7)
f10
dev.off()
## png 
##   2

#CD Trans -> cluster 29

f11 <- FeaturePlot(integrated, features = c("Slc26a4", "Insrr", 
    "Rhbg"), min.cutoff = "q9")
f11

pdf(paste0(outdir, "/15_FeaturePlot_CD-Trans.pdf"), width = 14, 
    height = 14)
f11
dev.off()
## png 
##   2

#Fibroblast

f12 <- FeaturePlot(integrated, features = c("Plac8", "S100a4", 
    "Pdgfrb"), min.cutoff = "q9")
f12

pdf(paste0(outdir, "/16_FeaturePlot_Fib.pdf"), width = 14, height = 14)
f12
dev.off()
## png 
##   2

#Macro -> cluster 22

f13 <- FeaturePlot(integrated, features = c("C1qa", "Cd68", "C1qb"), 
    min.cutoff = "q9")
f13

pdf(paste0(outdir, "/17_FeaturePlot_Macro.pdf"), width = 14, 
    height = 14)
f13
dev.off()
## png 
##   2

#PMN -> cluster 36

f14 <- FeaturePlot(integrated, features = c("S100a8", "Ly6g", 
    "S100a9"), min.cutoff = "q9")
f14

pdf(paste0(outdir, "/18_FeaturePlot_PMN.pdf"), width = 14, height = 14)
f14
dev.off()
## png 
##   2

#B lymph -> cluster 37

f15 <- FeaturePlot(integrated, features = c("Cd79a", "Cd79b", 
    "Cd19"), min.cutoff = "q9")
f15

pdf(paste0(outdir, "/19_FeaturePlot_Blymph.pdf"), width = 14, 
    height = 14)
f15
dev.off()
## png 
##   2

#Tlymph -> cluster 30

f16 <- FeaturePlot(integrated, features = c("Ltb", "Cd4", "Cxcr6"), 
    min.cutoff = "q9")
f16

pdf(paste0(outdir, "/20_FeaturePlot_Tlymph.pdf"), width = 14, 
    height = 14)
f16
dev.off()
## png 
##   2

#NK -> cluster 30

f17 <- FeaturePlot(integrated, features = c("Gzma", "Nkg7"), 
    min.cutoff = "q9")
f17

pdf(paste0(outdir, "/21_FeaturePlot_NK.pdf"), width = 14, height = 7)
f17
dev.off()
## png 
##   2

#Novel1

f18 <- FeaturePlot(integrated, features = c("Slc27a2", "Lrp2", 
    "Cdca3"), min.cutoff = "q9")
f18

pdf(paste0(outdir, "/22_FeaturePlot_Novel1.pdf"), width = 14, 
    height = 14)
f18
dev.off()
## png 
##   2
# library(Seurat)
DefaultAssay(integrated) <- "RNA"
clusters <- levels(integrated@active.ident)
conserved.markers <- data.frame(matrix(ncol = 14))
for (c in clusters) {
    print(c)
    markers.c <- FindConservedMarkers(integrated, ident.1 = c, 
        grouping.var = "sample.id", verbose = T, logfc.threshold = -Inf, 
        min.pct = -Inf, min.cells.feature = -Inf, min.cells.group = -Inf)
    markers.c <- cbind(data.frame(cluster = rep(c, dim(markers.c)[1]), 
        gene = rownames(markers.c)), markers.c)
    write.table(markers.c, file = paste0(outdir, "/23_markers_", 
        c, ".txt"))
    colnames(conserved.markers) <- colnames(markers.c)
    conserved.markers <- rbind(conserved.markers, markers.c)
    head(conserved.markers)
}
## [1] "0"
## [1] "1"
## [1] "2"
## [1] "3"
## [1] "4"
## [1] "5"
## [1] "6"
## [1] "7"
## [1] "8"
## [1] "9"
## [1] "10"
## [1] "11"
## [1] "12"
## [1] "13"
## [1] "14"
## [1] "15"
## [1] "16"
## [1] "17"
## [1] "18"
## [1] "19"
## [1] "20"
## [1] "21"
## [1] "22"
conserved.markers <- conserved.markers[-1, ]
conserved.markers <- conserved.markers[, c(1:2, 13:14, 3:12)]
head(conserved.markers)
##               cluster          gene max_pval minimump_p_val C24_p_val
## D630023F18Rik       0 D630023F18Rik        0              0         0
## Spp2                0          Spp2        0              0         0
## Slc34a3             0       Slc34a3        0              0         0
## Slc5a12             0       Slc5a12        0              0         0
## Car3                0          Car3        0              0         0
## Alpl                0          Alpl        0              0         0
##               C24_avg_log2FC C24_pct.1 C24_pct.2 C24_p_val_adj C0_p_val
## D630023F18Rik      0.5152721     0.395     0.020             0        0
## Spp2               2.3501061     0.950     0.176             0        0
## Slc34a3            0.7243040     0.533     0.022             0        0
## Slc5a12            1.0784786     0.788     0.077             0        0
## Car3               0.8505601     0.421     0.029             0        0
## Alpl               1.1738811     0.870     0.155             0        0
##               C0_avg_log2FC C0_pct.1 C0_pct.2 C0_p_val_adj
## D630023F18Rik     0.9698330    0.663    0.086            0
## Spp2              2.5368215    0.983    0.339            0
## Slc34a3           0.8490152    0.581    0.044            0
## Slc5a12           1.6953147    0.912    0.190            0
## Car3              0.8773502    0.419    0.065            0
## Alpl              1.0206583    0.817    0.243            0

Only top markers that are positive markers

conserved.markers$marker.type <- apply(conserved.markers, 1, function(x) {
  y <- as.numeric(x)
  if ( (if (is.na(y[6])) {TRUE} else {y[6]>0})
       & (if (is.na(y[11])) {TRUE} else {y[11]>0})
       # & (if (is.na(y[16])) {TRUE} else {y[16]>0})
       # & (if (is.na(y[21])) {TRUE} else {y[21]>0})
       # & (if (is.na(y[26])) {TRUE} else {y[26]>0})
       # & (if (is.na(y[31])) {TRUE} else {y[31]>0})
       # & (if (is.na(y[36])) {TRUE} else {y[36]>0})
       # & (if (is.na(y[41])) {TRUE} else {y[41]>0}) 
       )
    {"POS"}
  else if ( ( if (is.na(y[6])) {TRUE} else {y[6]<0})
       & (if (is.na(y[11])) {TRUE} else {y[11]<0})
       # & (if (is.na(y[16])) {TRUE} else {y[16]<0})
       # & (if (is.na(y[21])) {TRUE} else {y[21]<0})
       # & (if (is.na(y[26])) {TRUE} else {y[26]<0})
       # & (if (is.na(y[31])) {TRUE} else {y[31]<0})
       # & (if (is.na(y[36])) {TRUE} else {y[36]<0})
       # & (if (is.na(y[41])) {TRUE} else {y[41]<0})
       ) 
    {"NEG"}
  else {"UND"}
  })
conserved.markers <- conserved.markers[, c(1:4, 15, 5:14)]
openxlsx::write.xlsx(conserved.markers, paste0(outdir, "/23_conserved_markers_PC50_res0.5_23clusters.xlsx"), 
    colNames = T)
head(conserved.markers)
##               cluster          gene max_pval minimump_p_val marker.type
## D630023F18Rik       0 D630023F18Rik        0              0         POS
## Spp2                0          Spp2        0              0         POS
## Slc34a3             0       Slc34a3        0              0         POS
## Slc5a12             0       Slc5a12        0              0         POS
## Car3                0          Car3        0              0         POS
## Alpl                0          Alpl        0              0         POS
##               C24_p_val C24_avg_log2FC C24_pct.1 C24_pct.2 C24_p_val_adj
## D630023F18Rik         0      0.5152721     0.395     0.020             0
## Spp2                  0      2.3501061     0.950     0.176             0
## Slc34a3               0      0.7243040     0.533     0.022             0
## Slc5a12               0      1.0784786     0.788     0.077             0
## Car3                  0      0.8505601     0.421     0.029             0
## Alpl                  0      1.1738811     0.870     0.155             0
##               C0_p_val C0_avg_log2FC C0_pct.1 C0_pct.2 C0_p_val_adj
## D630023F18Rik        0     0.9698330    0.663    0.086            0
## Spp2                 0     2.5368215    0.983    0.339            0
## Slc34a3              0     0.8490152    0.581    0.044            0
## Slc5a12              0     1.6953147    0.912    0.190            0
## Car3                 0     0.8773502    0.419    0.065            0
## Alpl                 0     1.0206583    0.817    0.243            0
library(Seurat)
x <- factor(integrated$integrated_snn_res.0.5)
head(x)
## AAACCCAAGATGGCGT--C0 AAACCCAAGCAGTCTT--C0 AAACCCAAGCGAGGAG--C0 
##                    6                    1                    3 
## AAACCCAAGTAGGGTC--C0 AAACCCAAGTTTGTCG--C0 AAACCCACACTAACGT--C0 
##                    2                    5                    5 
## Levels: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
levels(x)
##  [1] "0"  "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14"
## [16] "15" "16" "17" "18" "19" "20" "21" "22"
library(plyr)
x <- revalue(x, c(`0` = "PCT-S1", `1` = "PST-S3", `2` = "PT-S2", 
    `3` = "PST-S3", `4` = "LOH", `5` = "Endo", `6` = "Conn Tubule", 
    `7` = "Macro", `8` = "Distal CT", `9` = "CD-IC", `10` = "Endo", 
    `11` = "CD-PC", `12` = "Fib", `13` = "PCT-S1", `14` = "CD Trans", 
    `16` = "Fib", `17` = "NK", `18` = "Podo", `19` = "Fib", `20` = "Fib", 
    `21` = "B lymph", `22` = "PMN"))
integrated$annotation.1 <- x
head(integrated$annotation.1)
## AAACCCAAGATGGCGT--C0 AAACCCAAGCAGTCTT--C0 AAACCCAAGCGAGGAG--C0 
##          Conn Tubule               PST-S3               PST-S3 
## AAACCCAAGTAGGGTC--C0 AAACCCAAGTTTGTCG--C0 AAACCCACACTAACGT--C0 
##                PT-S2                 Endo                 Endo 
## 17 Levels: PCT-S1 PST-S3 PT-S2 LOH Endo Conn Tubule Macro Distal CT ... PMN
Idents(integrated) <- "annotation.1"
library(ggsci)
levels <- levels(integrated$annotation.1)
colors.annotation.1 <- pal_ucscgb("default", alpha = 1)(26)[1:length(levels)]
names(colors.annotation.1) <- levels
colors.annotation.1
##      PCT-S1      PST-S3       PT-S2         LOH        Endo Conn Tubule 
## "#FF0000FF" "#FF9900FF" "#FFCC00FF" "#00FF00FF" "#6699FFFF" "#CC33FFFF" 
##       Macro   Distal CT       CD-IC       CD-PC         Fib    CD Trans 
## "#99991EFF" "#999999FF" "#FF00CCFF" "#CC0000FF" "#FFCCCCFF" "#FFFF00FF" 
##          15          NK        Podo     B lymph         PMN 
## "#CCFF00FF" "#358000FF" "#0000CCFF" "#99CCFFFF" "#00FFFFFF"
slices <- rep(1, length(levels))
pie(slices, col = colors.annotation.1, labels = names(colors.annotation.1))

library(Seurat)
d2 <- DimPlot(integrated, label = TRUE, label.size = 4, group.by = "annotation.1", 
    cols = colors.annotation.1, repel = T)
d2

pdf(paste0(outdir, "/24_Dimplot_newidents.pdf"), width = 13, 
    height = 9)
d2
dev.off()
## png 
##   2
d3 <- DimPlot(integrated, group.by = "sample.id", split.by = "sample.id", 
    pt.size = 0.2, ncol = 2, cols = colors.samples)
d3

pdf(paste0(outdir, "/25_DimPlot_newidents_split_by_samples.pdf"), 
    width = 16, height = 9)
d3
dev.off()
## png 
##   2

Identify cells expressing Il6

DefaultAssay(integrated) <- "RNA"
f19 <- FeaturePlot(integrated, features = "Il6", order = T, label = T, 
    label.size = 3)
f19

pdf(paste0(outdir, "/26_FeaturePlot_Il6.pdf"), width = 11, height = 10)
f19
dev.off()
## png 
##   2
f20 <- FeaturePlot(integrated, features = c("Il6"), split.by = "sample.id", 
    max.cutoff = 3, cols = c("grey", "red"), order = T)
f20

pdf(paste0(outdir, "/27_FeaturePlot_Il6-sham-CLP.pdf"), width = 19, 
    height = 10)
f20
dev.off()
## png 
##   2
library(ggplot2)
library(cowplot)
theme_set(theme_cowplot())
integrated$celltype.stim <- paste(Idents(integrated), integrated$sample.id, 
    sep = "_")
integrated$celltype <- Idents(integrated)
Idents(integrated) <- "celltype"
plots <- VlnPlot(integrated, features = c("Il6"), split.by = "sample.id", 
    group.by = "celltype", pt.size = 0, combine = FALSE)
library(patchwork)
wrap_plots(plots = plots, ncol = 1)

d <- DotPlot(integrated, features = "Il6", group.by = "celltype.stim")
openxlsx::write.xlsx(d$data, paste0(outdir, "/28_IL6_expn_per_celltype_stim.xlsx"))
d

pdf(paste0(outdir, "/29_DotPlot_IL6_celltype_stim.pdf"), width = 5, 
    height = 9)
d
dev.off()
## png 
##   2
Idents(integrated) <- "integrated_snn_res.0.5"
cluster19 <- WhichCells(integrated, idents = "19")
# others <- WhichCells(integrated, idents = "33", invert = T)
d <- DimPlot(integrated, label=T, group.by="celltype", cells.highlight= list(cluster19), cols.highlight = c("darkblue"
                                                                                                       # , "darkred"
                                                                                                       ), cols= "grey")
d

pdf(paste0(outdir, "/30_DimPlot_integrated_label_group.by_celltype_cell.highlight_cluster19.pdf"))
d
dev.off()
## png 
##   2
saveRDS(integrated, paste0(outdir, "/31.integrated.rds"))
integrated$res.0.5.stim <- paste(integrated$integrated_snn_res.0.5, 
    integrated$sample.id, sep = "_")
d <- DotPlot(integrated, features = "Il6", group.by = "res.0.5.stim")
openxlsx::write.xlsx(d$data, paste0(outdir, "/32_IL6_expn_per_cluster_stim.xlsx"))
Idents(integrated) <- "integrated_snn_res.0.5"
f20 <- FeaturePlot(integrated, features = c("Il6"), split.by = "sample.id", 
    max.cutoff = 3, cols = c("grey", "red"), order = T, label = T)
f20

pdf(paste0(outdir, "/33_FeaturePlot_Il6-sham-CLP_w_labels.pdf"), 
    width = 19, height = 10)
f20
dev.off()
## png 
##   2

Updated cell types

library(Seurat)
x <- factor(integrated$integrated_snn_res.0.5)
head(x)
## AAACCCAAGATGGCGT--C0 AAACCCAAGCAGTCTT--C0 AAACCCAAGCGAGGAG--C0 
##                    6                    1                    3 
## AAACCCAAGTAGGGTC--C0 AAACCCAAGTTTGTCG--C0 AAACCCACACTAACGT--C0 
##                    2                    5                    5 
## Levels: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
levels(x)
##  [1] "0"  "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14"
## [16] "15" "16" "17" "18" "19" "20" "21" "22"
library(plyr)
x <- revalue(x, c(`0` = "PT-S1", `1` = "PT-S3", `2` = "PT-S2", 
    `3` = "PT-S3", `4` = "LOH", `5` = "Endo", `6` = "Conn Tubule", 
    `7` = "Macro", `8` = "Distal Conv T", `9` = "CD-IC", `10` = "Endo", 
    `11` = "CD-PC", `12` = "Fib", `13` = "PT-S1", `14` = "CD-Trans", 
    `15` = "CD-IM", `16` = "Fib", `17` = "NK", `18` = "Podo", 
    `19` = "Fib", `20` = "Fib", `21` = "B lymph", `22` = "PMN"))
integrated$annotation.1 <- x
head(integrated$annotation.1)
## AAACCCAAGATGGCGT--C0 AAACCCAAGCAGTCTT--C0 AAACCCAAGCGAGGAG--C0 
##          Conn Tubule                PT-S3                PT-S3 
## AAACCCAAGTAGGGTC--C0 AAACCCAAGTTTGTCG--C0 AAACCCACACTAACGT--C0 
##                PT-S2                 Endo                 Endo 
## 17 Levels: PT-S1 PT-S3 PT-S2 LOH Endo Conn Tubule Macro Distal Conv T ... PMN
Idents(integrated) <- "annotation.1"
cell.types <- c("Endo", "Podo", "PT-S1", "PT-S2", "PT-S3", "LOH", 
    "Distal Conv T", "Conn Tubule", "CD-PC", "CD-IC", "CD-Trans", 
    "CD-IM", "Fib", "Macro", "PMN", "B lymph", "NK")
integrated$annotation.1 <- factor(integrated$annotation.1, levels = cell.types)
library(ggsci)
levels <- levels(integrated$annotation.1)
colors.annotation.1 <- pal_ucscgb("default", alpha = 1)(26)[1:length(levels)]
names(colors.annotation.1) <- levels
colors.annotation.1
##          Endo          Podo         PT-S1         PT-S2         PT-S3 
##   "#FF0000FF"   "#FF9900FF"   "#FFCC00FF"   "#00FF00FF"   "#6699FFFF" 
##           LOH Distal Conv T   Conn Tubule         CD-PC         CD-IC 
##   "#CC33FFFF"   "#99991EFF"   "#999999FF"   "#FF00CCFF"   "#CC0000FF" 
##      CD-Trans         CD-IM           Fib         Macro           PMN 
##   "#FFCCCCFF"   "#FFFF00FF"   "#CCFF00FF"   "#358000FF"   "#0000CCFF" 
##       B lymph            NK 
##   "#99CCFFFF"   "#00FFFFFF"
slices <- rep(1, length(levels))
pie(slices, col = colors.annotation.1, labels = names(colors.annotation.1))

library(Seurat)
d2 <- DimPlot(integrated, label = TRUE, label.size = 4, group.by = "annotation.1", 
    cols = colors.annotation.1, repel = T)
d2

pdf(paste0(outdir, "/34_Dimplot_updated_newidents.pdf"), width = 13, 
    height = 9)
d2
dev.off()
## png 
##   2
library(Seurat)
Idents(integrated) <- "annotation.1"
d2 <- DimPlot(integrated, label = FALSE, cols = colors.annotation.1) + 
    NoLegend()
d2

pdf(paste0(outdir, "/35_Dimplot_updated_newidents_NoLegend.pdf"), 
    width = 7, height = 7)
d2
dev.off()
## png 
##   2

DotPlot with cell markers

Endothelial Plat Endothelial Pecam1 Podocytes Nphs2 Podocytes Podxl PT-S1 Slc5a2 PT-S1 Slc5a12 PT-S2 Fxyd2 PT-S3 Atp11a PT-S3 Slc13a3 LOH Slc12a1 LOH Umod Distal CT Slc12a3 Distal CT Pvalb Conn Tubule Calb1 CD PC Aqp2 CD PC Hsd11b2 CD-IC Atp6v1g3 CD-IC Atp6v0d2 CD Trans Slc26a4 CD Trans Insrr CD Trans Rhbg Inner medullary collecting duct (CD-IM) Slc14a2 Fibroblast Plac8 Fibroblast S100a4 Fibroblast Pdgfrb Macro C1qa Macro Cd68 Macro C1qb PMN S100a8 PMN Ly6g PMN S100a9 B lymph Cd79a B lymph Cd79b B lymph Cd19 NK Gzma NK Nkg7

known.markers <- c("Plat", "Pecam1", "Nphs2", "Podxl", "Slc5a2", 
    "Slc5a12", "Fxyd2", "Atp11a", "Slc13a3", "Slc12a1", "Umod", 
    "Slc12a3", "Pvalb", "Calb1", "Aqp2", "Hsd11b2", "Atp6v1g3", 
    "Atp6v0d2", "Slc26a4", "Insrr", "Rhbg", "Slc14a2", "Plac8", 
    "S100a4", "Pdgfrb", "C1qa", "Cd68", "C1qb", "S100a8", "Ly6g", 
    "S100a9", "Cd79a", "Cd79b", "Cd19", "Gzma", "Nkg7")
DefaultAssay(integrated) <- "RNA"
d <- DotPlot(object = integrated, features = known.markers, cols = c("#03539C", 
    "#E82564"), dot.scale = 8, group.by = "annotation.1") + RotatedAxis()
d

pdf(paste0(outdir, "/36_DotPlot_known_markers_cell_types.pdf"), 
    width = 14, height = 7)
d
dev.off()
## png 
##   2
saveRDS(integrated, paste0(outdir, "/37.annotated.rds"))

Session Information

sessionInfo()
## R version 4.0.3 (2020-10-10)
## Platform: x86_64-conda-linux-gnu (64-bit)
## Running under: Red Hat Enterprise Linux Server release 6.8 (Santiago)
## 
## Matrix products: default
## BLAS:   /gpfs/fs1/data/omicscore/Privratsky-Privratsky-20210215/scripts/conda/envs/privratsky/lib/libblas.so.3.8.0
## LAPACK: /gpfs/fs1/data/omicscore/Privratsky-Privratsky-20210215/scripts/conda/envs/privratsky/lib/liblapack.so.3.8.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats4    parallel  stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] data.table_1.13.6           gridExtra_2.3              
##  [3] forcats_0.5.1               stringr_1.4.0              
##  [5] purrr_0.3.4                 readr_1.4.0                
##  [7] tidyr_1.1.2                 tibble_3.0.6               
##  [9] tidyverse_1.3.0             SingleR_1.4.0              
## [11] celldex_1.0.0               SummarizedExperiment_1.20.0
## [13] Biobase_2.50.0              GenomicRanges_1.42.0       
## [15] GenomeInfoDb_1.26.0         IRanges_2.24.0             
## [17] S4Vectors_0.28.0            BiocGenerics_0.36.0        
## [19] MatrixGenerics_1.2.0        matrixStats_0.58.0         
## [21] dplyr_1.0.4                 ggsci_2.9                  
## [23] patchwork_1.1.1             cowplot_1.1.1              
## [25] ggplot2_3.3.3               Seurat_4.0.0               
## [27] SeuratObject_4.0.0          plyr_1.8.6                 
## 
## loaded via a namespace (and not attached):
##   [1] readxl_1.3.1                  backports_1.2.1              
##   [3] AnnotationHub_2.22.0          BiocFileCache_1.14.0         
##   [5] igraph_1.2.6                  lazyeval_0.2.2               
##   [7] splines_4.0.3                 BiocParallel_1.24.0          
##   [9] listenv_0.8.0                 scattermore_0.7              
##  [11] digest_0.6.27                 htmltools_0.5.1.1            
##  [13] magrittr_2.0.1                memoise_2.0.0                
##  [15] tensor_1.5                    cluster_2.1.1                
##  [17] ROCR_1.0-11                   globals_0.14.0               
##  [19] modelr_0.1.8                  colorspace_2.0-0             
##  [21] rvest_1.0.0                   blob_1.2.1                   
##  [23] rappdirs_0.3.3                ggrepel_0.9.1                
##  [25] haven_2.3.1                   xfun_0.20                    
##  [27] crayon_1.4.1                  RCurl_1.98-1.2               
##  [29] jsonlite_1.7.2                spatstat_1.64-1              
##  [31] spatstat.data_2.0-0           survival_3.2-7               
##  [33] zoo_1.8-8                     glue_1.4.2                   
##  [35] polyclip_1.10-0               gtable_0.3.0                 
##  [37] zlibbioc_1.36.0               XVector_0.30.0               
##  [39] leiden_0.3.7                  DelayedArray_0.16.0          
##  [41] BiocSingular_1.6.0            future.apply_1.7.0           
##  [43] abind_1.4-5                   scales_1.1.1                 
##  [45] DBI_1.1.1                     miniUI_0.1.1.1               
##  [47] Rcpp_1.0.6                    viridisLite_0.3.0            
##  [49] xtable_1.8-4                  reticulate_1.18              
##  [51] rsvd_1.0.3                    bit_4.0.4                    
##  [53] htmlwidgets_1.5.3             httr_1.4.2                   
##  [55] RColorBrewer_1.1-2            ellipsis_0.3.1               
##  [57] ica_1.0-2                     pkgconfig_2.0.3              
##  [59] uwot_0.1.10                   dbplyr_2.1.0                 
##  [61] deldir_0.2-9                  tidyselect_1.1.0             
##  [63] rlang_0.4.10                  reshape2_1.4.4               
##  [65] later_1.1.0.1                 AnnotationDbi_1.52.0         
##  [67] cellranger_1.1.0              munsell_0.5.0                
##  [69] BiocVersion_3.12.0            tools_4.0.3                  
##  [71] cachem_1.0.4                  cli_2.3.0                    
##  [73] ExperimentHub_1.16.0          generics_0.1.0               
##  [75] RSQLite_2.2.4                 broom_0.7.5                  
##  [77] ggridges_0.5.3                evaluate_0.14                
##  [79] fastmap_1.1.0                 yaml_2.2.1                   
##  [81] goftest_1.2-2                 fs_1.5.0                     
##  [83] knitr_1.31                    bit64_4.0.5                  
##  [85] fitdistrplus_1.1-3            RANN_2.6.1                   
##  [87] pbapply_1.4-3                 future_1.21.0                
##  [89] nlme_3.1-152                  sparseMatrixStats_1.2.0      
##  [91] mime_0.10                     formatR_1.7                  
##  [93] xml2_1.3.2                    rstudioapi_0.13              
##  [95] compiler_4.0.3                plotly_4.9.3                 
##  [97] curl_4.3                      png_0.1-7                    
##  [99] interactiveDisplayBase_1.28.0 spatstat.utils_2.0-0         
## [101] reprex_1.0.0                  stringi_1.5.3                
## [103] ps_1.5.0                      lattice_0.20-41              
## [105] Matrix_1.3-2                  vctrs_0.3.6                  
## [107] pillar_1.4.7                  lifecycle_1.0.0              
## [109] BiocManager_1.30.10           lmtest_0.9-38                
## [111] BiocNeighbors_1.8.0           RcppAnnoy_0.0.18             
## [113] bitops_1.0-6                  irlba_2.3.3                  
## [115] httpuv_1.5.5                  R6_2.5.0                     
## [117] promises_1.2.0.1              KernSmooth_2.23-18           
## [119] parallelly_1.23.0             codetools_0.2-18             
## [121] MASS_7.3-53.1                 assertthat_0.2.1             
## [123] withr_2.4.1                   sctransform_0.3.2            
## [125] GenomeInfoDbData_1.2.4        hms_1.0.0                    
## [127] mgcv_1.8-33                   beachmat_2.6.0               
## [129] grid_4.0.3                    rpart_4.1-15                 
## [131] rmarkdown_2.6                 DelayedMatrixStats_1.12.0    
## [133] Rtsne_0.15                    lubridate_1.7.10             
## [135] shiny_1.6.0
writeLines(capture.output(sessionInfo()), "./scripts/5_Clustering_res_0.5/5_Clustering_res_0.5.sessionInfo.txt")